package cn.qyd;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author 邱运铎
 * @date 2024-03-05 12:21
 */
public class YangHuiSanJiaoDemo {
    public static void main(String[] args) {
        boolean isContinue = true;
        while (isContinue) {
            Scanner scanner = new Scanner(System.in);
            System.out.print("请输入要打印的行数： ");
            int lines = scanner.nextInt();
            printYHSJ(lines);
            System.out.print("是否继续：0(结束) 1（继续） ");
            Scanner scanner1 = new Scanner(System.in);
            isContinue = scanner1.nextInt() == 0 ? false : true;
        }
    }

    public static void printYHSJ(int n) {
        int[][] yhsj = new int[n][n];
        for(int i = 0; i < n; i++) {
            yhsj[i][0] = 1;
            yhsj[i][i] = 1;
            for (int j =1; j < i;j++) {
                yhsj[i][j] = yhsj[i-1][j-1]+ yhsj[i-1][j];
            }
        }

        for (int i =0; i < n; i++) {
            for(int j = 0; j <= i;j++ ){
                System.out.print(yhsj[i][j] + " ");
            }
            System.out.println();
        }
    }
}
